package cn.wolfcode.service.impl;

import cn.wolfcode.domain.CustomerTransfer;
import cn.wolfcode.mapper.CustomerTransferMapper;
import cn.wolfcode.query.KeywordQueryObject;
import cn.wolfcode.service.ICustomerTransferService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerTransferServiceImpl implements ICustomerTransferService {
    @Autowired
    private CustomerTransferMapper customerTransferMapper;

    @Override
    public void delete(Long id) {
        customerTransferMapper.deleteByPrimaryKey(id);
    }
    @Override
    public void save(CustomerTransfer customerTransfer) {
        customerTransferMapper.insert(customerTransfer);
    }
    @Override
    public CustomerTransfer get(Long id) {
        return customerTransferMapper.selectByPrimaryKey(id);
    }
    @Override
    public List<CustomerTransfer> listAll() {
        return customerTransferMapper.selectAll();
    }
    @Override
    public void update(CustomerTransfer customerTransfer) {
        customerTransferMapper.updateByPrimaryKey(customerTransfer);
    }

    @Override
    public PageInfo<CustomerTransfer> query(KeywordQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),"id desc");
        List<CustomerTransfer> customerTransfers = customerTransferMapper.selectForList(qo);
        return new PageInfo<CustomerTransfer>(customerTransfers);
    }


}
